<template>
    <el-card class="box-card" v-show="show1">
        <template #header>
            <div class="card-header">
                <span>查看人员</span>
            </div>
        </template>
        <el-form :model="formData" style="margin: 0 20px;" disabled="true">
            <el-form-item label="人员名称" :label-width="80" prop="name">
                <el-input v-model="formData.name" class="custom-input gray-bg" />
            </el-form-item>

            <el-form-item label="农场职务" :label-width="80" prop="job">
                <el-input v-model="formData.job" class="custom-input gray-bg" />
            </el-form-item>
            <el-form-item label="登陆账号" :label-width="80" prop="account">
                <el-input v-model="formData.account" class="custom-input gray-bg" />
            </el-form-item>
            <el-form-item label="上级人员" :label-width="80" prop="top">
                <el-input v-model="formData.top" class="custom-input gray-bg" />
            </el-form-item>
            <el-form-item label="备注" :label-width="80" prop="note">
                <el-input v-model="formData.note" class="custom-input gray-bg" />
            </el-form-item>
        </el-form>
        <template #footer>
            <div class="footer-center">
                <el-button type="success" @click="show1 = false">关闭</el-button>
            </div>
        </template>
    </el-card>
</template>

<script lang='ts' setup>
import type { IPeople } from '@/interface/IPeople'
import { reactive, watch } from 'vue'

const { data } = defineProps(['data'])
const formData = reactive({
    name: '',
    job: '',
    account: '',
    top: '',
    note: ''
})
const show1 = defineModel({ required: true })
// 侦听父组件传的查看数据然后合并给表单
watch(() => data, (value: IPeople) => {
    console.log(value)
    if (value) {
        Object.assign(formData, value)
    }
})
</script>

<style lang='scss' scoped>
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

}

span {
    font-weight: 700;
    color: #fff;
}

.text {
    font-size: 14px;
}

.item {
    margin-bottom: 18px;
}

.box-card {
    width: 480px;
    height: 500px;
    background: #1C3846;
    color: #fff;
    margin: auto;
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    z-index: 1;
}

.footer-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

:deep(.custom-input .el-input__wrapper) {
    background-color: #2C4353 !important;
    border: none !important;
    // 去除聚焦时的阴影
    box-shadow: none !important;
}
</style>